package com.qf.zyh.common;

public class Pages {
    //当前页
    private int pageIndex;
    //页面行数
    private int pageSize;
    //总页数
    private int totalPage;
    //总条数
    private int totalCount;
    //起始行
    private int startRow;

    public Pages() {
    }

    public Pages(int pageIndex, int pageSize, int totalCount) {
        this.totalCount = totalCount;
        if (pageSize<=0) {
            this.pageSize=5;
        }else {
            this.pageSize=pageSize;
        }
        //总页数等于总行数除每页行数并想上取整墙砖int
        this.totalPage= (int) Math.ceil(this.totalCount/(this.pageSize+0.0));
        //当前页码处理
        if (pageIndex<=0) {
            this.pageIndex=1;
        }else if (pageIndex>=this.totalPage){
            this.pageIndex=this.totalPage;
        }else {
            this.pageIndex=pageIndex;
        }
        //起始行数处理为当前页-1乘以每页显示人数
        this.startRow=(this.pageIndex-1)*this.pageSize;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getStartRow() {
        return startRow;
    }

    public void setStartRow(int startRow) {
        this.startRow = startRow;
    }

}
